#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    long long total = accumulate(a.begin(), a.end(), 0LL);
    vector<long long> suf(n + 1, 0);
    for (int i = n - 1; i >= 0; i--) {
        suf[i] = suf[i + 1] + a[i];
    }
    long long ans = total;
    for (int i = 0; i < n; i++) {
        long long k = a[i];
        long long cost = k * x + (suf[i + 1] - k * (n - i - 1));
        if (cost < ans) {
            ans = cost;
        }
    }
    cout << ans << endl;
    return 0;
}